package com.jumi.microservice.controller;


import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.dto.wallet.api.WalletInOrOutListRequest;
import com.jumi.microservice.dto.wallet.api.WalletInOrOutListResponse;
import com.jumi.microservice.service.IWalletInOrOutService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author by mazhao
 * @Classname WalletInOrOutService
 * @Description TODO
 * @Date 2020/7/22 10:47
 */
@Api(tags = {"出入账接口"})
@RestController
public class WalletInOrOutController extends BaseController {

    @DubboReference
    IWalletInOrOutService walletInOrOutService;

//    @Resource
//    UserWalletMapper userWalletMapper;

    @PostMapping("/wallet/dic")
    @ApiOperation("出入账类型")
    public ResponseResult dic() {
        return ResponseResult.success(walletInOrOutService.dic());
    }

    @PostMapping("api/wallet/inOrOutList")
    @ApiOperation("提现金额明细")
    public TableDataInfo<List<WalletInOrOutListResponse>> getWalletInOrOutList(WalletInOrOutListRequest request) {
        Integer uid = getApiUserId();
        request.setUserId(uid.longValue());
        return walletInOrOutService.getWalletInOrOutList(request);
    }

    @PostMapping("api/wallet/waitCash")
    @ApiOperation("可提现金额")
    public ResponseResult<BigDecimal> getWaitCash() {
        Long uid = getApiUserId().longValue();
        return success(walletInOrOutService.waitCash(uid));
    }
}

